package com.jcli._java_swing_入门教程pdf._01_简单应用程序;

import javax.swing.*;

/**
 * @author li
 * @version 1.0
 * @belongsProject novel_20230923
 * @belongsPackage com.jcli._java_swing_入门教程pdf
 * @className HelloWorld
 * @description TODO  HelloWorld示例
 * @createTime 2024-01-11  08:48
 */
public class HelloWorld extends JFrame {
    private JTextField jTextField;
    private JButton jButton;
    private JLabel jLabel;

    public HelloWorld() {
        super();
        this.setSize(300, 200);
        this.getContentPane().setLayout(null);
        this.add(getJLabel(), null);
        this.add(getJButton(), null);
        this.add(getJTextFiled(), null);
        this.setTitle("HelloWorld");
    }


    private JButton getJButton() {
        if (jButton == null) {
            jButton = new JButton();
            jButton.setBounds(103, 110, 71, 27);
            jButton.setText("OK");
        }
        return jButton;
    }

    private JLabel getJLabel() {
        if (jLabel == null) {
            jLabel = new JLabel();
            jLabel.setBounds(34, 49, 53, 18);
            jLabel.setText("Name:");
        }
        return jLabel;
    }

    private JTextField getJTextFiled() {
        if (jTextField == null) {
            jTextField = new JTextField();
            jTextField.setBounds(96, 49, 160, 20);
        }
        return jTextField;
    }

    public static void main(String[] args) {
        HelloWorld w = new HelloWorld();
        w.setVisible(true);
    }
}
